
#include "qyLogMgr.h"
#include "qyLogger.h"

template<> qyLogMgr * qySingleton<qyLogMgr>::m_sSingleton = NULL;

//-----------------------------------------------------------------------
qyLogMgr::qyLogMgr()
{
}

//-----------------------------------------------------------------------
qyLogMgr::~qyLogMgr()
{
	ReleaseAllLoggers();
}

//-----------------------------------------------------------------------
void qyLogMgr::AddLogFile(const std::string fileName)
{
	if ( !m_loggerList[fileName] )
	{
		m_loggerList[fileName] = new qyLogger();
		m_loggerList[fileName]->SetLogFile( fileName );
	}
}

//-----------------------------------------------------------------------
qyLogger * qyLogMgr::SetLogFile(const std::string fileName)
{
	m_pLogger = m_loggerList[fileName];
	return m_pLogger;
}

//-----------------------------------------------------------------------
void qyLogMgr::ReleaseAllLoggers()
{
	LoggerList::iterator end = m_loggerList.end();
	for ( LoggerList::iterator it = m_loggerList.begin(); it != end; ++it )
	{
		qyLogger *logger = it->second;
		delete logger;
	}
	m_loggerList.clear();
}

//-----------------------------------------------------------------------
qyLogger * qyLogMgr::GetLogger(void)
{
	return m_pLogger;
}
